<?php
$loader->requireOnce('includes/Insurance/InsuranceInfo.class.php');
$loader->requireOnce('includes/Insurance/InsuranceRuleManager.class.php');
$loader->requireOnce('includes/Insurance/InsuranceCalculator.class.php');
class InsuranceEngine {
    private $db;

    function __construct(){
        $this->db = $GLOBALS['frame']['adodb']['db'];
    }

    public static function createInsuranceCalculator($objInsuranceInfo, $totalPrice) {
        // Get InsuranceRuleManager object
    	if (isset($_SESSION['insuranceRuleManager'])) {
            $objManager   =   $_SESSION['insuranceRuleManager'];
        }
        else {
            $_SESSION['insuranceRuleManager'] =   new InsuranceRuleManager();
            $objManager   =   $_SESSION['insuranceRuleManager'];
        }
        // Get InsuranceRule object
        $objRule   =   $objManager->getInsuranceRule($objInsuranceInfo, $totalPrice);

        // InsuranceCalculator object
        $objCalculator =   new InsuranceCalculator($objRule);
        return $objCalculator;
    }

}
?>